﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using WindowsFormsApplication1.BLL;
using Millionaire;

namespace WindowsFormsApplication1
{
    public partial class FrmRandom : Form
    {
        LinhVucBLL lvBLL;
        CauHoiBLL chBLL;
        public FrmRandom()
        {
            InitializeComponent();
            lvBLL = new LinhVucBLL();
            chBLL = new CauHoiBLL();
            lbLinhVuc.DisplayMember = "TenLinhVuc";
            lbLinhVuc.ValueMember = "MaLinhVuc";
            lbLinhVuc.DataSource = lvBLL.GetAll();
        }

        private void btnRandom_Click(object sender, EventArgs e)
        {
            label1.Text = chBLL.Random().CauHoi1;
        }

        private void btnRanDomMaLV_Click(object sender, EventArgs e)
        {
            int maLV = (int)lbLinhVuc.SelectedValue;
            CauHoi ch = chBLL.RandomLV(maLV,(int)numericUpDown1.Value);
            label1.Text = ch.MaCauHoi.ToString() + ch.CauHoi1;
        }

        private void btnRandomNhieuLV_Click(object sender, EventArgs e)
        {
            List<int> listLV = new List<int>();
            for (int i = 0; i < lbLinhVuc.SelectedItems.Count; i++)
            {
                listLV.Add(((LinhVuc)lbLinhVuc.SelectedItems[i]).MaLinhVuc);
            }
            label1.Text = chBLL.RandomNhieuLV(listLV, (int)numericUpDown1.Value).CauHoi1;

        }
    }
}
